#include "Bullet.h"

Bullet::Bullet(void)
{
	_timeAnimation=500; //500miliseconds
}
Bullet::Bullet(float x, float y, float vx, float vy, int deltaTime,int resourceName,CResourceManager* rm):MovingObject(x,y,vx,vy,deltaTime,resourceName,rm)
{
	_firstY=y;
}
Bullet::Bullet(int x, int y, int Width, int Height, float vx, float vy, int deltaTime, LPD3DXSPRITE spriteHandler, LPDIRECT3DTEXTURE9 image):MovingObject(x,y,Width,Height,vx,vy,deltaTime,spriteHandler,image)
{
	_firstY=y;
}
void Bullet::SetTimeAnimation(float _time)
{
	_timeAnimation=_time;
	_timeStartAnimation=GetTickCount();
}

void Bullet::SetXY(float _eX,float _eY)
{
	_x=_eX;
	_y=_eY;
}
void Bullet::SetVX(float vx)
{
	_vx=vx;
}
void Bullet::SetVY(float vy)
{
	_vy=vy;
}
void Bullet::Move()
{
	if( (_vy<0) && (_y<_firstY-HIGH_BULLET))  //bullet go up
	{
		_vy*=(-1);
	}
	_x+=_vx;
	_y+=_vy;
}
void Bullet::Render()
{
	_sprite=_spriteBullet;
	float _timeNow=GetTickCount();
	if(_timeNow-_timeStartAnimation<_timeAnimation)
	{
		_sprite->Render(_x,_y);
	}

}